<template>
  <footer>
    <ul>
      <li v-for="(item, index) in footNav" :key="index">
        <router-link :to="item.href">
          <i>
            <img :src="navIndex == index ? item.urlActive: item.url" alt="">
          </i>
          <span :class="{'active':navIndex == index ? true: false}">{{item.title}}</span>
        </router-link>
      </li>
    </ul>
  </footer>
</template>
<script>
  import index from "../../assets/images/index.png"
  import indexIcon from "../../assets/images/index-icon.png"
  import user from "../../assets/images/user.png"
  import userIcon from "../../assets/images/user-icon.png"
  export default {
    name:'Footer',
    data() {
      return {
        footNav: [{
          title: '首页',
          href: '/',
          url:  index,
          urlActive: indexIcon,
        },
          {
            title: '我的',
            href: '/user',
            url: user,
            urlActive: userIcon
          }
        ]
      }
    },
    props: {
      navIndex: {
        type: Number,
        default: 0
      }
    },
    methods: {}
  }
</script>

<style lang="less" scoped >
  footer {
    width: 100%;
    max-width: 750px;
    height: 50px;
    position: fixed;
    bottom: 0;
    border-top: 1px solid #ededed;
    padding: 6px 0 4px;
    box-sizing: border-box;
    background: #fff;

    ul {
      display: flex;
      width: 100%;

      li {
        flex: 1;
        float: left;

        a {
          display: block;

          i {
            display: block;
            height: 22px;
            width: 22px;
            margin: auto;
          }

          span {
            display: block;
            height: 18px;
            line-height: 20px;
            color: #727272;
            font-size: 12px;
            text-align: center;
          }
          .active {
            color: #000;
          }
        }
      }
    }
  }
</style>
